module.exports = function(app) {
  var express = require('express');
  var reporttargetsRouter = express.Router();

  var list =       {
          "_links" : {
            "self" : {
              "href" : "http://localhost/api/v1/reporttargets{?page,size,sort,projection}",
              "templated" : true
            },
            "search" : {
              "href" : "http://localhost/api/v1/reporttargets/search"
            }
          },
          "_embedded" : {
            "reporttargets" : [ {
              "id" : 2,
              "createdAt" : "2015-10-15T08:01:28.217+0000",
              "archived" : false,
              "target" : "http://e7a85f1309664744bd5172e56ef5c73e",
              "catalog" : "URL",
              "verifyUrl" : "http://e7a85f1309664744bd5172e56ef5c73e/d40f89ea2831444eafb3f0e8ff8756aa.txt",
              "verified" : false,
              "verifyAt" : null,
              "_links" : {
                "self" : {
                  "href" : "http://localhost/api/v1/reporttargets/2{?projection}",
                  "templated" : true
                },
                "creator" : {
                  "href" : "http://localhost/api/v1/reporttargets/2/creator"
                }
              }
            } ]
          },
          "page" : {
            "size" : 20,
            "totalElements" : 1,
            "totalPages" : 1,
            "number" : 0
          }
        };

  reporttargetsRouter.get('/', function(req, res) {
    res.send(list);
  });

  reporttargetsRouter.post('/', function(req, res) {
    var turl = req.params.target;
    res.status(201).end();
  });

  reporttargetsRouter.get('/:id', function(req, res) {
    var id = req.params.id,
        all = list._embedded.reporttargets,
        one;
    for(var i = 0; i<all.length; i++ ) {
        if (all[i].id + "" === id) {
          return all[i];
        }
    }
    res.send(one);
  });

  reporttargetsRouter.put('/:id', function(req, res) {
    res.send({
      'reporttargets': {
        id: req.params.id
      }
    });
  });

  reporttargetsRouter.delete('/:id', function(req, res) {
    res.status(204).end();
  });

  app.use('/api/v1/reporttargets', reporttargetsRouter);
};
